﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Services.Identity.Domain.Entities;

namespace Services.Identity.Infrastructure.Configs;

public class UserMessageConfig : IEntityTypeConfiguration<UserMessage>
{
    public void Configure(EntityTypeBuilder<UserMessage> builder)
    {
        builder.ToTable("T_UserOfflineMessage");
        builder.HasKey(x => x.MessageId).IsClustered();
        builder.Property(x => x.MessageId).UseHiLo();
        builder.HasMany(x => x.UnsentUsers).WithOne(x => x.UserMessage).HasForeignKey(x => x.MessageId);
    }
}
